package com.game.base.glideV4;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.FitCenter;
import com.game.base.R;
import com.game.base.glideV4.tranform.RoundBitmapTranformation;
import com.game.base.glideV4.utils.ImageLoaderV4;

import androidx.annotation.DrawableRes;

/**
 * Glide图片请求处理类
 */
public class ImageLoader {

    public static void loadCircleAvatar(Context context, String model, ImageView view) {
        ImageLoaderV4.getInstance().displayCircleImage(context, model, view, R.drawable.default_circle_head);
    }

    public static void loadRoundAvatar(Context context, String model, ImageView view) {
        ImageLoaderV4.getInstance().displayRoundImage(context, model, view, R.drawable.default_head, 8);
    }

    /**
     * CenterCrop加载图片
     */
    public static void loadCenterCrop(Context context, String model, ImageView view) {
        ImageLoaderV4.getInstance().displayImageByNet(context, model, view, R.drawable.default_pic, new CenterCrop());
    }

    public static void loadCenterCrop(Context context, String model, ImageView view, int defResImg, int errResImg) {
        ImageLoaderV4.getInstance().displayImageByNet(context, model, view, defResImg, new CenterCrop());
    }

    public static void loadCenterCropInResource(Context context, int resId, ImageView view) {
        ImageLoaderV4.getInstance().displayImageInResource(context, resId, view, R.drawable.default_pic, new CenterCrop());
    }

    /**
     * FitCenter加载图片
     */
    public static void loadFitCenter(Context context, String model, ImageView view) {
        ImageLoaderV4.getInstance().displayImageByNet(context, model, view, R.drawable.default_pic, new FitCenter());
    }

    /**
     * 图片圆角处理: 默认全角处理，其他需求自行重载方法
     */
    public static void loadRoundCenterCrop(Context context, String model, ImageView view) {
        ImageLoaderV4.getInstance().displayImageByNet(context, model, view, R.drawable.default_pic, new RoundBitmapTranformation(8));
    }

    public static void loadRoundCenterCropInResource(Context context, int resId, ImageView view) {
        ImageLoaderV4.getInstance().displayImageInResource(context, resId, view, R.drawable.default_pic, new RoundBitmapTranformation(8));
    }

    public static void loadRoundCenterCropInResource(Context context, int resId, ImageView view, int radius) {
        ImageLoaderV4.getInstance().displayImageInResource(context, resId, view, R.drawable.default_pic, new RoundBitmapTranformation(radius));
    }

    /**
     * 图片圆角处理: 默认全角处理，其他需求自行重载方法
     */
    public static void loadRoundCenterCrop(Context context, String model, ImageView view, int radius) {
        ImageLoaderV4.getInstance().displayImageByNet(context, model, view, R.drawable.default_pic, new RoundBitmapTranformation(radius));
    }

    public static void loadBlur(Context context, String model, ImageView view, int level, @DrawableRes int defaultPic) {
        ImageLoaderV4.getInstance().displayBlurImage(context, model, view, defaultPic, level);
    }
}
